package com.joshuait.sbswf.web;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.joshuait.sbswf.entity.Post;
import com.joshuait.sbswf.service.PostService;

@Controller
@RequestMapping(value = "/index")
public class IndexController {
	private static final Logger logger = LoggerFactory.getLogger(IndexController.class);

	@Autowired
	private PostService postService;

	//查询
	@RequestMapping
	public String list(Model model) {
		logger.info("start");
		List<Post> newPosts = postService.getNewPosts();
		model.addAttribute("newPosts", newPosts);
		
		List<Post> recommendPosts = postService.getRecommendPosts();
		model.addAttribute("recommendPosts", recommendPosts);
		
		logger.info("end");
		return "index";
	}
	
}
